import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    currentUser: null // 用于存储当前登录用户的信息
  },
  mutations: {
    SET_CURRENT_USER(state, user) {
      state.currentUser = user;
    }
  },
  actions: {
    setCurrentUser({ commit }, user) {
      commit('SET_CURRENT_USER', user);
    }
  },
  getters: {
    currentUser(state) {
      return state.currentUser;
    }
  }
});